package com.yt.controller;

import com.yt.entity.Author;
import com.yt.entity.CommonResult;
import com.yt.entity.Novel;
import com.yt.service.AuthorService;
import com.yt.service.NovelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
public class AuthorController {

    @Resource
    AuthorService authorService;
    @Resource
    NovelService novelService;

    @RequestMapping("/author/{id}")
    public CommonResult<Author> getAuthor(@PathVariable(name = "id")Integer id){
        Author author=authorService.getAuthorById(id);
        log.info(novelService.feigntimeout());
        CommonResult<List<Novel>> re=novelService.getNovelsByAid(id);
        List<Novel> novels=re.getT();
        author.setNovels( novels);
        CommonResult<Author> result=new CommonResult<>();
        result.setCode(200);
        result.setT(author);
        result.setInfo("数据正常，但未加载小说内容");
        return result;
    }

}
